﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AMS.DataAccess.Sys.BO;

public partial class User_ucUserDetail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public bool ValidateUser()
    {
        return true;
    }

    public bool GetUserInfo(UserInfo user)
    {
        if (!ValidateUser())
        {
            return false;
        }

        user.Alias = txtAlias.Text;
        user.IDCard = txtIDCard.Text;
        user.LoginName = txtLoginName.Text;
        user.Email = txtMail.Text;
        user.Mobile = txtMobile.Text;
        user.Name = txtName.Text;
        user.Tel = txtTel.Text;
        user.WorkNumber = txtWorkNumber.Text;
        user.Note = txtNote.Text;

        if (!string.IsNullOrEmpty(txtBrithday.Text))
        {
            user.Birthday = DateTime.Parse(txtBrithday.Text);
        }
        if (drpSex.SelectedIndex > 0)
        {
            user.Sex = (SexEnum)int.Parse(drpSex.SelectedValue);
        }
        if (chkPatentAttoney.Checked)
        {
            user.isPatentAttoney = true;
        }
        if (chkTrademarkAttoney.Checked)
        {
            user.isTrademarkAttoney = true;
        }

        return true;
    }

    public void ShowUser(UserInfo user)
    {
        txtAlias.Text = user.Alias;
        txtBrithday.Text = Utils.DateTimeToString(user.Birthday);
        txtIDCard.Text = user.IDCard;
        txtLoginName.Text = user.LoginName;
        txtMail.Text = user.Email;
        txtMobile.Text = user.Mobile;
        txtName.Text = user.Name;
        txtNote.Text = user.Note;
        txtTel.Text = user.Tel;
        txtWorkNumber.Text = user.WorkNumber;
        chkPatentAttoney.Checked = user.isPatentAttoney;
        chkTrademarkAttoney.Checked = user.isTrademarkAttoney;
        // TODO: 显示用户图片

        if (user.Sex == SexEnum.Male)
        {
            drpSex.SelectedIndex = 1;
        }
        else if (user.Sex == SexEnum.Female)
        {
            drpSex.SelectedIndex = 2;
        }
        else
        {
            drpSex.SelectedIndex = 0;
        }

    }
}
